package com.taofuxn.admin.common.model;

import java.io.Serializable;

/**
 * @author wong
 * @Date: 2020-12-03
 * @Version: 1.0
 */
public class PageRequest<T> implements Serializable {

    /**
     * 页码
     */
    private int page = 1;

    /**
     * 每页记录数
     */
    private int limit = 10;

    private T param;

    public PageRequest() {
    }

    public PageRequest(int page, int limit) {
        this.page = page;
        this.limit = limit;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    public T getParam() {
        return param;
    }

    public void setParam(T param) {
        this.param = param;
    }

    /**
     * 返回偏移量
     * @return
     */
    public int getOffset() {
        int offset = (page - 1) * limit;
        return Math.max(offset, 0);
    }
}
